package com.example.siyun.controller.shouyecontroller;

import com.example.siyun.pojo.Results;
import com.example.siyun.pojo.UserList;
import com.example.siyun.service.shouyeservice.AccountServer;
import com.example.siyun.util.PageResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * @Auther: 全
 * @Date: 2022/9/26 09:33
 * @Description:首页模块的账户设置
 */
@Slf4j
@RestController
public class AccountController {

    @Autowired
    private AccountServer accountServer;

    /**
     * 获取账户设置的信息
     * @param session HTTP会话, username 获取登录的用户名
     * @return 返回信息以及账户的信息
     */
    @RequestMapping("/Primary/getAccount")
    public PageResult getAccount(HttpSession session, String username){
        log.info("获取账户设置的信息");
        String loginname = (String) session.getAttribute("loginname");
        UserList acc = accountServer.getAcc(loginname);
//        System.out.println(acc);

        PageResult result = new PageResult();
        result.setMessage("成功");
        result.setData(acc);
        log.info("获取账户设置的信息成功");
        return result;
    }

}
